import requests
import uncurl


class __indicator_query__():
    def __query_room_name__(self):
        # URL 地址
        url = 'http://10.10.80.200:7944/api/eventmonitor/indicatorQuery/readRoomNameVarious'
        # url = 'http://localhost:7944/api/eventmonitor/indicatorQuery/readRoomNameVarious'

        headers = {
            'Content-Type': 'application/json',  # 如果你发送的是JSON数据
            'combine-token': '053562d9-1f26-48b6-a2fd-b9de6a7021b5,65820e0f-d576-411d-aadb-818d7bb47d93'
        }

        # JSON 数据

        # data = {
        #     'queryMethod': 'scan',
        #     'regionId': '2907',
        #     'roomNameInput': '',
        #     'labelCode': '1234567891',
        #     'latitude': '',
        #     'longitude': '',
        #     'pageIndex': 1,
        #     'pageSize': 10
        # }

        data = {
            'queryMethod': 'text',
            'regionId': '2901',
            'roomNameInput': '甘肃兰州',
            'labelCode': '',
            'latitude': '',
            'longitude': '',
            'pageIndex': 1,
            'pageSize': 10
        }

        # 发送 POST 请求
        response = requests.post(url, json=data, headers=headers)

        # 打印响应的内容
        print(response.text)

    def __query_ne_name__(self):
        # URL 地址
        url = 'http://10.10.80.200:7944/api/eventmonitor/indicatorQuery/readNeNameByRoomName'
        # url = 'http://localhost:7944/api/eventmonitor/indicatorQuery/readRoomNameVarious'

        headers = {
            'Content-Type': 'application/json',  # 如果你发送的是JSON数据
            'combine-token': '7d19b975-c48a-4baf-882b-6f6f4854b34f,3e73292d-36b0-49d6-882c-301c80f165f3'
        }

        # JSON 数据

        data = {
            'indicator': '101443704',
            'roomName': '中国甘肃酒泉玉门市玉门服务区无线机房',
            'roomId': 'C1BE8D448D4BF662E053054DEE0A6466',
            'deviceName': '',
            'deviceId': '',
            'neNameInput': 'JQ_玉门_玉门服务区',
            'neType': '',
            'subMajor': '',
            'pageIndex': 1,
            'pageSize': 10
        }

        # 发送 POST 请求
        response = requests.post(url, json=data, headers=headers)

        # 打印响应的内容
        print(response.text)

    def __query_indicator_by_ne_name__(self):
        # URL 地址
        url = 'http://10.10.80.200:7944/api/eventmonitor/indicatorQuery/queryIndicatorInfo'
        # url = 'http://localhost:7944/api/eventmonitor/indicatorQuery/queryIndicatorInfo'

        headers = {
            'Content-Type': 'application/json',  # 如果你发送的是JSON数据
            'combine-token': '053562d9-1f26-48b6-a2fd-b9de6a7021b5,65820e0f-d576-411d-aadb-818d7bb47d93'
        }

        # JSON 数据
        data = {
            "indicator": "101443704",
            "regionId": "",
            "roomName": "",
            "roomId": "",
            "subMajor": "",
            "neName": "JQ_玉门_玉门服务区_Z_T_H_773984",
            "deviceName": "",
            "deviceId": "",
            "neType": "",
            "portName": "",
            "neId": "",
            "rmuid": "",
            "verdor": "",
            "serviceCode": "",
            "mainMajor": "",
            "objectType": 1,
            "sheetId": "GS-906-240328-00001",
            "insProcId": "54553"
        }

        # 发送 POST 请求
        response = requests.post(url, json=data, headers=headers)

        # 打印响应的内容
        print(response.text)

    def __query_curl_(self):
        curl_command = '''
        curl 'http://10.10.80.200:9088/api/process-engine/todo_groupby_procid' \
      -H 'Accept: application/json' \
      -H 'Accept-Language: en-US,en;q=0.9' \
      -H 'Cache-Control: no-cache' \
      -H 'Connection: keep-alive' \
      -H 'Content-Type: application/json;charset=UTF-8' \
      -H 'Pragma: no-cache' \
      -H 'Referer: http://10.10.80.200:9088/MochaITOM/newProcessList/pendingList' \
      -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36' \
      -H 'combine-token: 1bd89856-f50e-4aff-b633-6cb76a511a29,2a9b1f79-8ed9-4300-927b-31e4c6392c02' \
      --insecure
      '''

        req = uncurl.parse_context(curl_command)

        response = requests.request(
            method=req.method,
            url=req.url,
            headers=req.headers,
            data=req.data,
            verify=False
        )

        print(response.json())


